﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace 设计模式之禅.抽象工厂模式
{

    #region 产品A

    public abstract class ProductA
    {
        public abstract string Say();
    }

    public class ProductA1 : ProductA
    {
        public override string Say()
        {
            return "ProductA1";
        }
    }
    public class ProductA2 : ProductA
    {
        public override string Say()
        {
            return "ProductA2";
        }
    }

    #endregion


    #region 产品B

    public abstract class ProductB
    {
        public abstract string Say();
    }

    public class ProductB1 : ProductB
    {
        public override string Say()
        {
            return "ProductB1";
        }
    }
    public class ProductB2 : ProductB
    {
        public override string Say()
        {
            return "ProductB2";
        }
    }

    #endregion




    public abstract class Creator
    {
        public abstract ProductA ProductAFactoryMethod();
        public abstract ProductB ProductBFactoryMethod();
    }

    public class Product1Creator : Creator
    {
        public override ProductA ProductAFactoryMethod()
        {
            return new ProductA1();
        }
        public override ProductB ProductBFactoryMethod()
        {
            return new ProductB1();
        }
    }


    public class Product2Creator : Creator
    {
        public override ProductA ProductAFactoryMethod()
        {
            return new ProductA2();
        }
        public override ProductB ProductBFactoryMethod()
        {
            return new ProductB2();
        }
    }

}
